<!DOCTYPE html>
<html class="no-js css-menubar" lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
        <meta name="description" content="bootstrap admin template">
        <meta name="author" content="">
        <script type="text/javascript" src="../_resource/js/header.js"></script>
        <script>
            var RUN_FUNCS = [];
            Breakpoints();
        </script>
        <style type="text/css">
            .list-table table td, .list-table table th{background:#fff; text-align:center;}
            .__access{display: none;}
            .__access{display: none;}
        </style>
    </head>
    <body class="dashboard">
        <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->

        <nav class="site-navbar navbar navbar-default navbar-fixed-top navbar-mega" role="navigation" id="navbardefaultmodel">
            <script type="text/javascript" src="../_resource/js/include.js" onload="HM.SomeFun('head_html')"></script>
        </nav>
        <div class="site-menubar">
            <div class="site-menubar-body" id="site-menubar-body">
                <script type="text/javascript" src="../_resource/js/include.js" onload="HM.SomeFun('nav_html')"></script>
            </div>
        </div>

        <!-- Page -->
        <div class="page">
            <div class="page-content container-fluid">
                <div class="list-table">
                    <div class="panel panel-bordered list-table-search">
                        <!--<div class="panel-body">
                            <form class="form-inline search-form" id="searchForm" name="searchForm" method="post" action="http://admin.html.me/Authtool/index" target="_self">
                                <div class="search-row">
                                    <div id="keyword-form-item"  class="form-group">
                                        <label for="keyword" class="control-label ">Keyword:</label>
                                        <input type="text" name="keyword" id="keywords" class="form-control"/>
                                    </div>
                                    <button class="btn btn-success" type="submit">
                                        Search
                                    </button>
                                </div>
                            </form>
                        </div>-->
                    </div>
                    <div class="panel ">
                        <div class="panel-body">
                            <div class="list-btns margin-bottom-15 " style="height: 36px;">
                                <a class="btn btn-primary" id="recruiter_click" href="javascript:window.loadToolData(1,'recruiter');">Recruiter Verification</a>
                                <a class="btn btn-danger" id="company_click" href="javascript:window.loadToolData(1,'company');" style="color:#666;background-color:#FFFFFF;border-color:#666;">Company Verification</a>
                            </div>
                            <table id="tabel201709201431258552549" border="0" cellpadding="6" cellspacing="1" class="table table-bordered  checkListTable">
                                <thead class="list-thead">
                                    <tr>
                                        <td class="nosort" width="38" data-width="38" style="text-align:center; line-height: normal;">
                                            <span class="checkbox-custom checkbox-primary">
                                                <input class="selectable-all" type="checkbox" onclick="$.tableCheckHandler(this)">
                                                <label></label>
                                            </span>
                                        </td>
                                        <td style="text-align:center;white-space:nowrap;" width="100" code="userid">
                                            <span>UserID</span>
                                        </td>
                                        <td style="text-align:center;white-space:nowrap;" code="verify_doc">
                                            <span>Verification Document</span>
                                        </td>
                                        <td style="text-align:center;white-space:nowrap;" code="date">
                                            <span>Date</span>
                                        </td>
                                        <td class="nosort" style="text-align:center;white-space:nowrap;" width="200">
                                            <span>Action</span>
                                        </td>
                                    </tr>
                                </thead>
                                <tbody class="list-tbody" id="tool-table"></tbody>
                            </table>
                            <nav class="pagination-nav" id="tool-pagenation"></nav>
                            <script type="text/javascript">
                                $(document).ready(function () {
                                    window.loadToolData = function(page = 1,document_type='recruiter'){
                                        $.setLoading($('#tool-table'));
                                        Api.Get('getAuthToolList', {status_key: 'pending', document_type: document_type, per_page: 10 , page : page}, function (object, error) {
                                            if (object['message'] && object['status_code'] && object['message'] == 'OK' && object['status_code'] == 200) {
                                                if(document_type == 'company'){
                                                    $("#recruiter_click").css({
                                                        'color'           :'#666',
                                                        'background-color':'#FFFFFF',
                                                        'border-color'    :'#666'
                                                    });
                                                    $("#company_click").css({
                                                        'color'           :'#fff',
                                                        'background-color':'#358fe4',
                                                        'border-color'    :'#2c8ae3'
                                                    });
                                                } else {
                                                    $("#company_click").css({
                                                        'color'           :'#666',
                                                        'background-color':'#FFFFFF',
                                                        'border-color'    :'#666'
                                                    });
                                                    $("#recruiter_click").css({
                                                        'color'           :'#fff',
                                                        'background-color':'#358fe4',
                                                        'border-color'    :'#2c8ae3'
                                                    });
                                                }
                                                $.setLoading($('#tool-table'), 1);
                                                var tableHtml = '', trNums = object['data']['data'].length;
                                                if(trNums > 0){
                                                    for (var i = 0; i < trNums; ++i) {
                                                        tableHtml = tableHtml + Api.render('<tr class="tr-1 {evenOrOdd}" key="{pk}" primary="userid">' +
                                                                '<td width="38" style="text-align:center; line-height: normal;">' +
                                                                '<span class="checkbox-custom checkbox-primary">' +
                                                                '<input class="selectable-item" type="checkbox"  name="key" id="row-{pk}" value="{pk}"  />' +
                                                                '<label for="row-{pk}"></label>' +
                                                                '</span>' +
                                                                '</td>' +
                                                                '<td code="userid"><a href="{editUrl}" target="_blank">{pk}</a></td>' +
                                                                '<td code="verify_doc"><a href="{verify_doc}" target="_blank">{verify_doc}</a></td>' +
                                                                '<td code="verify_date">{verify_date}</td>' +
                                                                '<td class="list-item-action">' +
                                                                '<button class="btn btn-primary" type="button" code="ver_re" data-toggle="verify" onclick="return doMake(1,{ver_re})">VERIFY</button>&nbsp;' +
                                                                '<button class="btn btn-danger" type="button" code="ver_re"  data-toggle="reject" onclick="return doMake(2,{ver_re})">REJECT</button>' + 
                                                                '</td>' +
                                                                '</tr>', {
                                                                    'evenOrOdd': object['data']['data'][i]['id'] % 2 == 1 ? 'odd' : 'even',
                                                                    'pk': document_type == 'recruiter' ? object['data']['data'][i]['recruiter_id'] : object['data']['data'][i]['company_id'],
                                                                    'verify_doc': object['data']['data'][i]['url'],
                                                                    'verify_date': object['data']['data'][i]['created_at'],
                                                                    'ver_re': "'"+object['data']['data'][i]['company_id'] + '_' + document_type + '_' + object['data']['data'][i]['recruiter_id']+"'",
                                                                    'editUrl':document_type == 'recruiter' ? Api.U('/User/edit.html', {id: object['data']['data'][i]['recruiter_id']}) : Api.U('/Company/edit.html', {id: object['data']['data'][i]['company_id']})
                                                                });
                                                    }
                                                
                                                    if (tableHtml) {
                                                        $('#tool-table').html(tableHtml);
                                                        if ($('#tool-table').data('inited') != 1) {
                                                            $('#tool-table').data('inited', 1);
                                                            var minwidth = 0;
                                                            var isFixedColumns = minwidth > 0 && $('#tabel201709201431258552549').width() < minwidth;
                                                            var table = $('#tabel201709201431258552549').DataTable({
                                                                fixedHeader: true,
                                                                autoWidth: isFixedColumns,
                                                                scrollCollapse: true,
                                                                paging: false,
                                                                info: false,
                                                                searching: false,
                                                                scrollX: true,
                                                                destroy: true,
                                                                order: [[0, '']],
                                                                columnDefs: [
                                                                    {targets: 'nosort', orderable: false, sSortAsc: false}
                                                                ]
                                                            }).on('order.dt', function () {
                                                                var order = table.order()[0];
                                                                var code = $('thead td', this).eq(order[0]).attr('code');
                                                            });
                                                            if (isFixedColumns) {
                                                                new $.fn.dataTable.FixedColumns(table, {
                                                                    leftColumns: 1,
                                                                    rightColumns: 1
                                                                });
                                                            }
                                                        }
                                                    }
                                                    
                                                    if (object['data']['data']) {
                                                        var pageString = Api.getAdminPagenation(totalRows = object['data']['total'], totalPages = object['data']['last_page'], page, window.loadToolData);
                                                        $('#tool-pagenation').html(pageString);
                                                        $('.pagination li').click(function () {
                                                            if (!isNaN(clickPage = parseInt($(this).data('page')))) {
                                                                window.loadToolData(clickPage,document_type);
                                                            }
                                                            return false;
                                                        });
                                                    }
                                                } else {
                                                    $('#tool-table').html('');
                                                    $('#tool-pagenation').html('');
                                                    $('#tool-table').data('inited', 1);
                                                    var minwidth = 0;
                                                    var isFixedColumns = minwidth > 0 && $('#tabel201709201431258552549').width() < minwidth;
                                                    var table = $('#tabel201709201431258552549').DataTable({
                                                        fixedHeader:    true,
                                                        autoWidth:  isFixedColumns,
                                                        scrollCollapse: true,
                                                        paging:         false,
                                                        info:       false,
                                                        searching:  false,
                                                        scrollX:        true,
                                                        destroy:        true,
                                                        order:      [[0, '']],
                                                        columnDefs:     [{
                                                            targets:'nosort', orderable:false, sSortAsc:false
                                                        }]
                                                    }).on('order.dt', function () {
                                                        var order = table.order()[0];
                                                        var code = $('thead td', this).eq(order[0]).attr('code');
                                                    });
                                                    if (isFixedColumns) {
                                                        new $.fn.dataTable.FixedColumns(table, {
                                                        leftColumns: 1,
                                                                rightColumns: 1
                                                        });
                                                    }                     
                                                }
                                            } else {
                                                $.showError('Something Error, Retry Please.', 300, function () {});
                                                return true;
                                            }
                                        });
                                    }
                                    loadToolData(1,'recruiter');
                                });
                                
                                //click
                                function doMake(status,info){
                                    var arr = info.split('_');
                                    var type         = arr[1],
                                        company_id   = arr[0],
                                        recruiter_id = arr[2];
                                    if(status == 1){
                                        $.showConfirm('Are you sure you want to verify？', function(){
                                            $("#confirmModal").remove();
                                            $('.modal-backdrop').remove();
                                            $.setLoading($('#tool-table'));
                                            if(type == 'recruiter'){
                                                Api.Put('updateVerifyRecruiter', {recruiter_id : recruiter_id , company_id : company_id}, function (object, error) {
                                                    if (object['message'] && object['status_code'] && object['message'] == 'OK' && object['status_code'] == 200) {
                                                        $.setLoading($('#tool-table'), 1);
                                                        $.showSuccess('Recruiter Tool Successfully.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    } else {
                                                        $.showError('Something Error, Retry Please.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    }
                                                });
                                            } else {
                                                Api.Put('updateVerifyCompnay', {recruiter_id : recruiter_id , company_id : company_id}, function (object, error) {
                                                    if (object['message'] && object['status_code'] && object['message'] == 'OK' && object['status_code'] == 200) {
                                                        $.setLoading($('#tool-table'), 1);
                                                        $.showSuccess('Company Tool Successfully.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    } else {
                                                        $.showError('Something Error, Retry Please.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    }
                                                });
                                            }
                                        });
                                    } else {
                                        $.showConfirm('Are you sure you want to reject？', function(){
                                            $("#confirmModal").remove();
                                            $('.modal-backdrop').remove();
                                            $.setLoading($('#tool-table'));
                                            if(type == 'recruiter'){
                                                Api.Put('updateRejectRecruiter', {recruiter_id : recruiter_id , company_id : company_id}, function (object, error) {
                                                    if (object['message'] && object['status_code'] && object['message'] == 'OK' && object['status_code'] == 200) {
                                                        $.setLoading($('#tool-table'), 1);
                                                        $.showSuccess('Recruiter Tool Successfully.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    } else {
                                                        $.showError('Something Error, Retry Please.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    }
                                                });
                                            } else {
                                                Api.Put('updateRejectCompnay', {recruiter_id : recruiter_id , company_id : company_id}, function (object, error) {
                                                    if (object['message'] && object['status_code'] && object['message'] == 'OK' && object['status_code'] == 200) {
                                                        $.setLoading($('#tool-table'), 1);
                                                        $.showSuccess('Company Tool Successfully.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    } else {
                                                        $.showError('Something Error, Retry Please.', 300, function () {
                                                            window.location.reload();
                                                        });
                                                    }
                                                });
                                            }
                                        });
                                    }
                                }
                            </script>
                        </div>
                    </div>
                </div>

                <!--<div class="modal fade" id="rejectModal" aria-labelledby="rejectModalLabel" role="dialog" tabindex="-1" aria-hidden="true" style="display: none;">
                    <div class="modal-dialog modal-simple modal-center">
                        <form class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">×</span>
                                </button>
                                <h4 class="modal-title" id="rejectModalLabel">Reason</h4>
                            </div>
                            <div class="modal-body">
                                <div class="row">

                                    <div class="form-group" style="height: 125px;">
                                        <div class="col-md-12">
                                            <textarea class="form-control" name="description" rows="5" data-fv-field="summary_content"></textarea>
                                            <small class="help-block" data-fv-validator="notEmpty" data-fv-for="summary_content" data-fv-result="NOT_VALIDATED" style="display: none;">
                                                The content is required and cannot be empty
                                            </small>
                                            <small class="help-block" data-fv-validator="stringLength" data-fv-for="summary_content" data-fv-result="NOT_VALIDATED" style="display: none;">
                                                The content must be less than 500 characters long
                                            </small>
                                        </div>
                                    </div>

                                    <div class="col-md-12 float-right">
                                        <button class="btn btn-primary btn-outline" data-dismiss="modal" type="button">Send</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>-->
            </div>

            <!-- Modal -->
            <div class="modal fade" id="confirmModal" aria-hidden="true" role="dialog" tabindex="-1">
                <div class="modal-dialog modal-center">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title"></h4>
                        </div>
                        <div class="modal-body">
                            <p></p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                            <button type="button" class="btn btn-primary"></button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="alertModal" aria-hidden="true" role="dialog" tabindex="-1">
                <div class="modal-dialog modal-center">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">×</span>
                            </button>
                            <h4 class="modal-title"></h4>
                        </div>
                        <div class="modal-body">
                            <p></p>
                        </div>
                    </div>
                </div>
            </div>
            <!-- End Modal -->
        </div>
        <!-- End Page -->

        <!-- Footer -->
        <script type="text/javascript" src="../_resource/js/footer.js"></script>
        <script>
                                (function (document, window, $) {
                                    'use strict';

                                    var Site = window.Site;
                                    $(document).ready(function () {
                                        Site.run();
                                        $('textarea[maxlength]').maxlength({
                                            threshold: 1000,
                                            placement: 'bottom-left-inside'
                                        });

                                        $.components.register("datepicker", {mode: "default", defaults: {autoclose: !0}});

                                        if (RUN_FUNCS.length > 0) {
                                            for (var i = 0; i < RUN_FUNCS.length; i++) {
                                                RUN_FUNCS[i].call();
                                            }
                                        }
                                    });
                                })(document, window, jQuery);


        </script>
    </body>
</html>